<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .modal {
      position: fixed;
      top: 50%;
      left: 50%;
      width: 500px;
      height: 400px;
      border: 1px solid #000;
      transform: translate(-50%, -50%);
    }
  </style>
</head>
<body>
  <div id="app">
    <h1>Teleport组件</h1>

    <div>
      <section>
        <main>
          <button @click="open = true">Open Modal</button>

          <Teleport to="body">
            <div v-if="open" class="modal">
              <p>Hello from the modal!</p>
              <button @click="open = false">Close</button>
            </div>
          </Teleport>
        </main>
      </section>
    </div>
  </div>

  <script src="../Vue.js"></script>

  <script>
    const { createApp } = Vue;
    
    const app = createApp({
      data() {
        return {
          open: false
        }
      },
      methods: {},
      components: {}
    })

    app.mount("#app")
  </script>
</body>
</html>